﻿Imports DTO
Public Class MonAnDuocDat_DAL
    Dim connect As Connection
    Dim stringCommand As String
    Dim monAnDuocDat As MonAnDuocDat
    Dim ds_monAnDuocDat As List(Of MonAnDuocDat)

    Public Function LoadData() As List(Of MonAnDuocDat)
        connect = New Connection()
        stringCommand = "Select * From MonAnDuocDat"
        ds_monAnDuocDat = New List(Of MonAnDuocDat)
        Dim dt As New DataTable()
        dt = connect.LoadData(stringCommand)
        For i As Integer = 0 To dt.Rows.Count - 1
            Dim id As Integer = dt.Rows(i)(0)
            Dim tiecCuoi As Integer = dt.Rows(i)(1)
            Dim monAn As Integer = dt.Rows(i)(2)

            monAnDuocDat = New MonAnDuocDat(id, tiecCuoi, monAn)
            ds_monAnDuocDat.Add(monAnDuocDat)
        Next
        Return ds_monAnDuocDat
    End Function

    Public Function Insert(ByVal monAnDuocDat As MonAnDuocDat)
        connect = New Connection()
        stringCommand = "Insert MonAnDuocDat(ID,TiecCuoi,MonAn) Values('" & monAnDuocDat.ID & "','" & monAnDuocDat.Tiệc_Cưới & "','" & monAnDuocDat.Món_Ăn & ")"
        Return connect.ExecuteData(stringCommand)
    End Function
End Class
